package my.mybatis.common.util;

import com.github.pagehelper.PageInfo;
import my.mybatis.common.response.PageResult;
import my.mybatis.common.response.base.ResultPageInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:wangbin.
 * @Description.
 * @Date:Created in 17:14 2017/9/18.
 * @Modified By:
 */
public class PageInfoToResult {

    public static void pageInfoToResult(PageInfo pageInfo, PageResult result)
    {
        Map<String,Object> data = new HashMap<String,Object>();
        data.put("list",pageInfo.getList());
        ResultPageInfo resultPageInfo =
                new ResultPageInfo(
                        pageInfo.getPageNum(),
                        pageInfo.getPageSize(),
                        pageInfo.getTotal(),
                        pageInfo.getPages());
        data.put("page",resultPageInfo);
        result.setData(data);
    }
}
